﻿using Kw.Combinatorics;
using System;

namespace Kw.CombinatoricsExamples
{
    class MulticombinationExample04
    {
        public class Pastry
        {
            private string name;
            public Pastry (string newName) { name = newName; }
            public override string ToString () { return name; }
        }

        class CombinationExample04
        {
            static void Main ()
            {
                Pastry[] Pastries = new Pastry[]
                {
                    new Pastry ("danish"),
                    new Pastry ("Eclair"),
                    new Pastry ("strudel"),
                    new Pastry ("donut"),
                    new Pastry ("croissant")
                };

                foreach (Multicombination pick3 in new Multicombination (Pastries.Length, 3).GetRows())
                {
                    foreach (var treat in Multicombination.Permute (pick3, Pastries))
                        Console.Write (treat + " ");
                    Console.WriteLine ();
                }
            }

            /* Output:

            danish danish danish
            danish danish Eclair
            danish danish strudel
            danish danish donut
            danish danish croissant
            danish Eclair Eclair
            danish Eclair strudel
            danish Eclair donut
            danish Eclair croissant
            danish strudel strudel
            danish strudel donut
            danish strudel croissant
            danish donut donut
            danish donut croissant
            danish croissant croissant
            Eclair Eclair Eclair
            Eclair Eclair strudel
            Eclair Eclair donut
            Eclair Eclair croissant
            Eclair strudel strudel
            Eclair strudel donut
            Eclair strudel croissant
            Eclair donut donut
            Eclair donut croissant
            Eclair croissant croissant
            strudel strudel strudel
            strudel strudel donut
            strudel strudel croissant
            strudel donut donut
            strudel donut croissant
            strudel croissant croissant
            donut donut donut
            donut donut croissant
            donut croissant croissant
            croissant croissant croissant

            */
        }
    }
}
